package ee.maoinvest.backend.model.dao;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

import ee.maoinvest.backend.model.data.ElectricityMeter;
import ee.maoinvest.backend.model.data.views.LocalTerritoryElectricityMeter;

public interface ElectricityMeterDAO 
{
	//basic CRUD
	public int insertElectricityMeter(ElectricityMeter electricityMeter);
	public ElectricityMeter getElectricityMeterByID(int electricityMeterID);
	public List<ElectricityMeter> getAllElectricityMeters();
	public int updateElectricityMeter(ElectricityMeter updatedElectricityMeter);
	public int deleteElectricityMeter(int electricityMeterID);
	
	//Eriliigiliste arvestite saamine
	public List<ElectricityMeter> getAllLocalTerritoryElectricityMetersThatHaveNotBeenWrittenOff();
	public List<ElectricityMeter> getAllSubstationMainElectricityMetersThatHaveNotBeenWrittenOff();
	public List<ElectricityMeter> getAllOuterTerritoryElectricityMetersThatHaveNotBeenWrittenOff();
	
	public List<ElectricityMeter> getAllLocalTerritoryElectricityMetersSubMetersThatHaveNotBeenWrittenOff(
			int localTerritoryElectricityMeterID);
	public List<ElectricityMeter> getAllSubstationMainElectricityMetersSubMetersThatHaveNotBeenWrittenOff(
			int substationMainElectricityMeterID);
	
	public List<ElectricityMeter> getAllLocalAndSubstationMainElectricityMetersThatHaveNotBeenWrittenOff();
	
	
	//kasutuses
	public List<ElectricityMeter> getAllElectricityMetersNotInUseAndNotWrittenOff();
	public List<ElectricityMeter> getAllElectricityMetersThatAreNotWrittenOff();
	public int setIsElectricityMeterInUse(int electricityMeterID, boolean isInUse);

	//public int writeElectricityMeterOff(ElectricityMeter electricityMeter);
	public HashMap<String, BigDecimal> getTheMostRecentReadingsInDatabase(int electricityMeterID);
	public List<ElectricityMeter> getListOfPotentialParentElectricityMetersExceptWithGivenID(int electricityMeterID);
	public List<ElectricityMeter> getListOfRelatedChildElectricityMeters(int electricityMeterID);
	public ElectricityMeter getParentElectricityMeter(int electricityMeterIDWhichParentToFind);
	public List<ElectricityMeter> getListOfPotentialParentElectricityMetersForLocalTerritoryMeterExceptWithGivenID(int localTerritoryElectricityMeterID);
	public LocalTerritoryElectricityMeter getLocalTerritoryElectricityMeterByID(int localTerritoryElectricityMeterID);
	public List<ElectricityMeter> getListOfPotentialParentElectricityMetersForLocalTerritoryMeterWhichParentToChangeNoChildrenIncluded(int localTerritoryElectricityMeterIDWhichParentToChange);
	
	/*Neid mitte maha lasta*/
	public List<ElectricityMeter> getAllPotentialParentMetersForLocalTerritoryMeterInsertion();
	public List<ElectricityMeter> getListOfPotentialParentElectricityMeters(
			int electricityMeterID);
	public List<ElectricityMeter> getAllElectricityMetersThatHaveNoChildMetersAndAreNotBoundedWithContractElseThanDefaultContract();
	public List<ElectricityMeter> getSubstationMainElectricityMetersConnectedWithSubstation(
			int substationID);
	
	public List<ElectricityMeter> getListOfElectricityMetersTakingPartInRegularReading();
	/**
	 * Parent meter itself is also included
	 * @return
	 */
	public List<ElectricityMeter> getListOfElectricityMetersAndTheirRelatedChildMeters(int electricityMeterID);
	public List<ElectricityMeter> findElectricityMetersByName(String electricityMeterNameInputValue, int maxRowsIntValue);
}
